package xj.graph2d.command;

import xj.graph2d.Arrow;
import xj.graph2d.GraphDocument;
import xj.graph2d.GraphEdgeBase;
import xj.graph2d.GraphView;

public class ReverseEdgeCommand extends AbstractCommand {

  public ReverseEdgeCommand(GraphView view, 
			    GraphDocument doc, 
			    GraphEdgeBase edge) { 
    super(view, doc);
    this.edge = edge;
    graph = doc;
  }

  public void execute() {
    doReverseEdge();
  }

  public void undo() {
    doReverseEdge();
  }

  void doReverseEdge() { 
    if (edge != null) { 
      //Arrow head = edge.getHeadArrow();
      //Arrow tail = edge.getTailArrow();
      //edge.setHeadArrow(tail);
      //edge.setTailArrow(head);

      //edge.setHeadOffset(0, 0);
      //edge.setTailOffset(0, 0);
      graph.reverseEdgeDirection(edge);

      canvas.repaint();
    }
  }

  protected GraphEdgeBase edge;
  protected GraphDocument graph;

}
